package day6.homework;

import org.junit.Test;

public class Demo {

	@Test
	public void test1() {
		Teacher teacher = null; // 在方法中声明的局部变量必须要手动初始化
		// The local variable teacher may not have been initialized
		// initialize  v
		System.out.println(teacher);// null  变量是null打印不会报NullPointerException
		// null.getAge();  null.id;  当null.方法()或者null.属性会报空指针异常
		// java.lang.NullPointerException 空指针异常
		System.out.println(teacher.id);
		System.out.println(teacher.getAge());
	}
	
	@Test
	public void test2() {
		// 默认new 的是无参构造方法
		Teacher teacher = new Teacher();
		teacher.setAge(23);
		System.out.println(teacher);
		System.out.println(teacher.toString());
		
		Teacher teacher2 = new Teacher(2, "王五", 23, 10000.0);
		System.out.println(teacher2);
	}
	
	@Test
	public void test3() {
		Vehicle vehicle = new Vehicle(100, 23);
		vehicle.move();
		vehicle.speedUp(10);
		vehicle.move();
		System.out.println(vehicle.getSpeed());
	}
	
	@Test
	public void test4() {
		Number number = new Number(3, 5);
		int result = number.add();
		System.out.println(result);
		result = number.sub();
		System.out.println(result);
	}
	
	@Test
	public void test5() {
		Rectangle rectangle = new Rectangle(3, 5);
		double mianJi = rectangle.mianJi();
		System.out.println(mianJi);
	}
	
	@Test
	public void test6() {
		Point point = new Point(3, 5);
		System.out.println(point);
		point.movePoint(2, -10);
		System.out.println(point);
	}
}
